package com.xyzwps.yaff.core;

import java.util.Map;
import java.util.Set;

public interface FlowContext {

    /**
     * Set Context Variable
     *
     * @param name  variable name which should be a valid identifier defined in
     *              {@link com.xyzwps.yaff.core.commons.Utils#isIdentifier}/
     * @param value variable value
     */
    void set(String name, Object value);

    /**
     * Get Context Variable
     *
     * @param name variable name which should be a valid identifier defined in
     *             {@link com.xyzwps.yaff.core.commons.Utils#isIdentifier}/
     * @return variable value
     */
    Object get(String name);

    /// Get all variable names which are set by {@link #set(String, Object)}.
    ///
    /// @return all variable names
    Set<String> getNames();

    /// Get all variables which are set by {@link #set(String, Object)} as a map.
    ///
    /// @return all variables as a map
    Map<String, Object> toMap();

    NodeContext getByNodeId(String nodeId);

    static FlowContext create() {
        return new SimpleFlowContext();
    }

}
